module.exports = function (app) {
  const swaggerUi = require("swagger-ui-express");
  const swaggerJSDoc = require("swagger-jsdoc");
  // Swagger定义
  const options = {
    swaggerDefinition: {
      openapi: "3.1.0",
      info: {
        title: "app-server",
        version: "1.0.0",
        description: "app-server的接口文档",
      },
      servers: [
        {
          url: "http://localhost:3000",
        },
      ],
    },
    apis: ["./routes/*.js", "./swagger-definition.js"], // 指定包含Swagger注释的路由文件路径
  };

  // 初始化Swagger-JSDoc
  const swaggerSpec = swaggerJSDoc(options);
  // 使用Swagger UI中间件
  app.use("/", swaggerUi.serve, swaggerUi.setup(swaggerSpec));
};
